package zhr.chapter10;

import java.io.File;

public class Example10_1 {
    public static void main(String[] args) {
        File currentDir =new File(".");
        System.out.println("Files in:"+currentDir.getAbsolutePath());
        String[] files=currentDir.list();
        int dirCount=0,fileCount=0;
        long fileSize=0;
        for(int i=0;i<files.length;i++){
            File tempFile=new File(files[i]);
            if(tempFile.isFile()){
                System.out.println(files[i]+"\t"+tempFile.length());
                fileCount++;
                fileSize=fileSize+tempFile.length();
            }
            if(tempFile.isDirectory()){
                System.out.println(files[i]+"\t<DIR>");
                dirCount++;
            }
        }
        System.out.println(fileCount+"File(e)\t"+fileSize+"Bytes");
        System.out.println(dirCount+"Dir(s)");
    }
}
